package cn.wolfcode.trip.base.mapper;

import cn.wolfcode.trip.base.domain.Answer;
import cn.wolfcode.trip.base.query.QueryObject;
import org.apache.ibatis.annotations.Param;
import sun.rmi.runtime.Log;

import java.util.List;

public interface AnswerMapper {
    int deleteByPrimaryKey(Long id);

    int insert(Answer record);

    Answer selectByPrimaryKey(Long id);

    List<Answer> selectAll(QueryObject qo);

    List<Answer> selectForList(@Param("qid") Long id, @Param("qo") QueryObject qo);

    int updateByPrimaryKey(Answer record);

    int getAnswerCountByQuestionId(Long id);

    // 维护顶答案表
    void remAnswerLike(@Param("uid") Long uid, @Param("aid") Long aid);

    void insAnswerLike(@Param("uid") Long uid, @Param("aid") Long aid);

    // 操作likes字段
    void delLike(Long aid);

    void addLike(Long aid);

    // 维护收藏答案表
    void remAnswerFav(@Param("uid") Long uid, @Param("aid") Long aid);

    void insAnswerFav(@Param("uid") Long uid, @Param("aid") Long aid);

    // 操作favs字段
    void delFav(Long aid);

    void addFav(Long aid);

    // 获取顶的回答
    Answer getLikeAnswerById(@Param("uid") Long uid, @Param("aid") Long aid);

    // 获取收藏的回答
    Answer getFavAnswerById(@Param("uid") Long uid, @Param("aid") Long aid);

    int getCommentCountByQuestionId(Long qid);

}